package edu.mit.media.fv.components
{
	import flash.display.*;
	import flash.events.MouseEvent;
	import flash.text.*;

	public class FVCell extends TextField
	{
		private var _index:int = -1;
		public function FVCell(x:int, y:int, width:int, height:int, index:int, text:String, action:Function = null)
		{
			super();
			this._index = index;
			
			var format:TextFormat = new TextFormat();
			format.align = TextFormatAlign.LEFT;
			format.bold = true;
			format.font = "Arial";
			format.size = height*0.8;
			format.color = 0xFFFFFF;
			
			this.defaultTextFormat = format;
			this.type = TextFieldType.DYNAMIC;
			this.selectable = false;
			this.x = x;
			this.y = y;
			this.width = width;
			this.height = height;
			//this.borderColor = 0x123456;
			//this.border = true;
			this.background = true;
			this.backgroundColor = 0x000000;
			this.text = text;
			this.mouseEnabled = true;
			
			this.addEventListener(MouseEvent.ROLL_OUT, processMouseOut);
			this.addEventListener(MouseEvent.ROLL_OVER, processMouseIn);
			
			if(action != null){
				this.addEventListener(MouseEvent.CLICK, action);
			}
		}
		
		private function processMouseIn(event:MouseEvent):void{
			this.backgroundColor = 0x9FC4F9;
		}
		private function processMouseOut(event:MouseEvent):void{
			this.backgroundColor = 0x000000;
		}
		
		public function get index():int{
			return this._index;
		}
		
	}
}